package main

import (
	"fmt"
	"math/rand"
	"time"
)

func bubbleSort(nums *[]int) {
	if nums == nil || len(*nums) == 0 {
		return
	}

	for i := 0; i < len(*nums); i++ {
		for j := 1; j < len(*nums); j++ {
			if (*nums)[j] < (*nums)[j-1] {
				temp := (*nums)[j-1]
				(*nums)[j-1] = (*nums)[j]
				(*nums)[j] = temp
			}
		}
	}
}

func main() {
	nums := make([]int, 100000)

	for i := 0; i < 1; i++ {
		for i := 0; i < len(nums); i++ {
			nums[i] = rand.Intn(10000000)
		}
		startTime := time.Now()
		bubbleSort(&nums)
		endTime := time.Now()

		//fmt.Println(nums)
		fmt.Println("time: ", endTime.Sub(startTime))
	}

}
